<template>
  <div ref="container" class="three-container">

  </div>
</template>

<script lang="ts">
import { defineComponent, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { refresh } from '@/three/index'

const watchParams = () => {
  const route = useRoute()
  const container = ref()
  watch([container, route], ([newContainer, newRoute]) => {
    if (!newContainer || newRoute.name !== 'three') return
    refresh(newContainer as HTMLElement, newRoute.params.id as string)
  }, {
    immediate: true
  })
  return {
    container
  }
}
export default defineComponent({
  name: 'three-index',
  setup () {
    return {
      ...watchParams()
    }
  }
})
</script>
<style lang="scss" scoped>
.three-container{
  height: 100%;
  position: relative;
}
</style>
